package streamAPI.operators;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import streamAPI.source.MyNoParallelSource;

/**
 * @author yue.cao
 * @since 09-28-2020
 */
public class DemoWithProcess {

	public static void main(String[] args) throws Exception {
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		DataStreamSource<Long> source = env.addSource(new MyNoParallelSource());


		SingleOutputStreamOperator<String> process = source.process(new ProcessFunction<Long, String>() {
			@Override
			public void processElement(Long value, Context ctx, Collector<String> out) throws Exception {
				out.collect(value.toString());
			}


		});

		process.print();
		env.execute();
	}

}
